<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
		<meta name="format-detection" content="telephone=no"/>
		<title>身份认证</title>
		<link href="css/lt_common.css" rel="stylesheet" />
		<link href="css/validate.css" rel="stylesheet" />
	</head>
	<body>
	<div class='page' title='身份认证'>
		<div class='panel_content'>	
			<div class="container">
				<div class="identity_authentication">
					<form id='myform'>
						<input type="text" id="staff_number" name="staff_number" placeholder="员工工号" />
						<input type="text" id="name" name="name" placeholder="员工姓名" />
						<input type="hidden" id="openid" name="openid" value="" />
						<input type="hidden" id="state" name="state" value="" />
					</form>
				</div>
				<div class="login">
					<input type="button" value="马上验证" onclick="authentic()"/>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
<script src="js/common.js"></script>
<script src="js/jquery.js"></script>
<script>

	var openid = getQueryString('openid');

	$('#openid').val(openid);

	function authentic(){
		var staff_number = $('#staff_number').val();
		if(staff_number==''){
			alert('员工工号不能为空');
			return;
		}

		var name = $('#name').val();
		if(name==''){
			alert('员工姓名不能为空');
			return;
		}
		
		dosmt();
	}
	
	//点击验证方法
	function dosmt(){
		$.ajax({
			cache: true,
			type: "POST",
			dataType: "JSON",
			url:API_URL+"agent/authentication",
			data:$('#myform').serialize(),
			async: false,
			error: function(request) {
				alert("Connection error");
			},
			success: function(jsonobj) {
			
				if(jsonobj.status.code == 0){
					//已认证,跳转主页,将openid传入
					var myData = jsonobj.data[0];
					var openid = myData.openid;
					window.location = 'guide_page.html?openid='+openid;
				}

				if(jsonobj.status.code == -1){
					alert('工号不存在或输入有误,请检查!');
					return;
				}
			}
		});
	}
</script>